<template>
  <tr>
    <td><input type="checkbox" v-model="obj.checked" /></td>
    <td>{{ obj.name }}</td>
    <td>{{ obj.price }}</td>
    <td>
      <button @click="minus" :disabled="obj.num <= 1">-</button>
      <span>{{ obj.num }} </span>
      <button @click="add">+</button>
    </td>
    <td>{{ obj.num * obj.price }}</td>
    <td><button @click="del(id)">删除</button></td>
  </tr>
</template>

<script>
export default {
  props: {
    id: Number,
    obj: {
      type: Object,
      require: true,
    },
  },
  methods: {
    add() {
      this.obj.num++;
    },
    minus() {
      this.obj.num--;
    },
    del(id) {
      this.$emit("del", id);
    },
  },
};
</script>

<style>
</style>